home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / WINPROGS / UPC12BS1.ZIP / UUCICO / MODEM.C < prev    next >
C/C++ Source or Header  |  1993-10-03  |  37KB  |  1,008 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    m o d e m . c                                                   */
  3. /*                                                                    */
  4. /*    High level modem control routines for UUPC/extended             */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*       Changes Copyright (c) 1989-1993 by Kendra Electronic         */
  9. /*       Wonderworks.                                                 */
  10. /*                                                                    */
  11. /*       All rights reserved except those explicitly granted by       */
  12. /*       the UUPC/extended license agreement.                         */
  13. /*--------------------------------------------------------------------*/
  14.  
  15. /*--------------------------------------------------------------------*/
  16. /*                          RCS Information                           */
  17. /*--------------------------------------------------------------------*/
  18.  
  19. /*
  20.  *    $Id: modem.c 1.31 1993/10/03 22:34:33 ahd Exp $
  21.  *
  22.  *    Revision history:
  23.  *    $Log: modem.c $
  24.  * Revision 1.31  1993/10/03  22:34:33  ahd
  25.  * Insure priority values are reset when loading modem information
  26.  *
  27.  * Revision 1.30  1993/10/03  20:43:08  ahd
  28.  * Move slowWrite to script.c
  29.  *
  30.  * Revision 1.29  1993/10/01  01:17:44  ahd
  31.  * Use atol() for reading port speed
  32.  *
  33.  * Revision 1.28  1993/09/29  13:18:06  ahd
  34.  * Clear raise before calling script processor in shutDown
  35.  *
  36.  * Revision 1.28  1993/09/29  13:18:06  ahd
  37.  * Clear raise before calling script processor in shutDown
  38.  *
  39.  * Revision 1.27  1993/09/29  05:25:21  ahd
  40.  * Correct resetting of raised flag
  41.  *
  42.  * Revision 1.26  1993/09/29  04:49:20  ahd
  43.  * Allow unique signal handler for suspend port processing
  44.  *
  45.  * Revision 1.25  1993/09/28  01:38:19  ahd
  46.  * Add configurable timeout for conversation start up phase
  47.  *
  48.  * Revision 1.24  1993/09/27  04:04:06  ahd
  49.  * Normalize references to modem speed to avoid incorrect displays
  50.  *
  51.  * Revision 1.23  1993/09/27  00:45:20  ahd
  52.  * Add suspend of serial port processing from K. Rommel
  53.  *
  54.  * Revision 1.22  1993/09/25  03:07:56  ahd
  55.  * Invoke set priority functions
  56.  *
  57.  * Revision 1.21  1993/09/23  03:26:51  ahd
  58.  * Never try to autobaud a network connection
  59.  *
  60.  * Revision 1.20  1993/09/20  04:46:34  ahd
  61.  * OS/2 2.x support (BC++ 1.0 support)
  62.  * TCP/IP support from Dave Watt
  63.  * 't' protocol support
  64.  *
  65.  * Revision 1.19  1993/08/03  03:11:49  ahd
  66.  * Add Description= line
  67.  *
  68.  * Revision 1.18  1993/07/13  01:13:32  ahd
  69.  * Correct message for systems waiting forever
  70.  *
  71.  * Revision 1.17  1993/07/05  14:47:05  ahd
  72.  * Drop obsolete  tag from "variablepacket"
  73.  * Set default timeout of 30 seconds for answer timeout
  74.  *
  75.  * Revision 1.16  1993/06/16  04:03:25  ahd
  76.  * Lower max wait time for NT
  77.  *
  78.  * Revision 1.15  1993/05/30  15:25:50  ahd
  79.  * Multiple driver support
  80.  *
  81.  * Revision 1.14  1993/05/30  00:04:53  ahd
  82.  * Multiple communications drivers support
  83.  *
  84.  * Revision 1.13  1993/04/15  03:21:06  ahd
  85.  * Add CD() call to hot login procedure
  86.  *
  87.  * Revision 1.12  1993/04/11  00:34:11  ahd
  88.  * Global edits for year, TEXT, etc.
  89.  *
  90.  * Revision 1.11  1993/04/05  04:35:40  ahd
  91.  * Set clear abort processing flag (norecover) from ulib.c
  92.  *
  93.  * Revision 1.10  1993/03/06  23:04:54  ahd
  94.  * make modem connected messages consistent
  95.  *
  96.  * Revision 1.9  1993/01/23  19:08:09  ahd
  97.  * Add additional shutDown() commands even when modem does not init
  98.  *
  99.  * Revision 1.8  1992/12/30  13:11:44  dmwatt
  100.  * Check for NULL brand pointer before comparing
  101.  *
  102.  * Revision 1.7  1992/12/18  12:05:57  ahd
  103.  * Flag variable packet as obsolete
  104.  *
  105.  * Revision 1.6  1992/11/28  19:51:16  ahd
  106.  * Add program exit time to waiting for callin message
  107.  * Make time parameter to callin() const
  108.  *
  109.  * Revision 1.5  1992/11/22  21:20:45  ahd
  110.  * Use strpool for const string allocation
  111.  *
  112.  * Revision 1.4  1992/11/19  03:01:21  ahd
  113.  * drop rcsid
  114.  *
  115.  * Revision 1.3  1992/11/18  03:48:24  ahd
  116.  * Move check of call window to avoid premature lock file overhead
  117.  *
  118.  * Revision 1.2  1992/11/15  20:12:17  ahd
  119.  * Clean up modem file support for different protocols
  120.  *
  121.  * Revision 1.1  1992/11/12  12:32:18  ahd
  122.  * Initial revision
  123.  *
  124.  */
  125.  
  126. /*--------------------------------------------------------------------*/
  127. /*                        System include files                        */
  128. /*--------------------------------------------------------------------*/
  129.  
  130. #include <limits.h>
  131. #include <stdio.h>
  132. #include <stdlib.h>
  133. #include <string.h>
  134. #include <ctype.h>
  135. #include <time.h>
  136. #include <limits.h>
  137. #include <sys/types.h>
  138.  
  139. /*--------------------------------------------------------------------*/
  140. /*                    UUPC/extended include files                     */
  141. /*--------------------------------------------------------------------*/
  142.  
  143. #include "lib.h"
  144. #include "hostable.h"
  145. #include "arpadate.h"
  146. #include "catcher.h"
  147. #include "checktim.h"
  148. #include "commlib.h"
  149. #include "dater.h"
  150. #include "dcp.h"
  151. #include "dcpsys.h"
  152. #include "hlib.h"
  153. #include "modem.h"
  154. #include "script.h"
  155. #include "security.h"
  156. #include "ssleep.h"
  157. #include "suspend.h"
  158. #include "usrcatch.h"
  159.  
  160. /*--------------------------------------------------------------------*/
  161. /*                          Global variables                          */
  162. /*--------------------------------------------------------------------*/
  163.  
  164. char *M_device = NULL;          /*Public to show in login banner     */
  165.  
  166. static char **answer, **initialize, **dropline, **ring, **connect;
  167. static char **noconnect;
  168. static char *dialPrefix, *dialSuffix;
  169. static char *M_suite;
  170. static char *dummy;
  171.  
  172. static KEWSHORT dialTimeout, modemTimeout, scriptTimeout;
  173. static KEWSHORT answerTimeout;
  174. static BPS inspeed;
  175. static KEWSHORT gWindowSize, gPacketSize;
  176. static KEWSHORT vWindowSize, vPacketSize;
  177. static KEWSHORT GWindowSize, GPacketSize;
  178.  
  179. KEWSHORT M_charDelay;
  180. KEWSHORT M_fPacketSize;
  181. KEWSHORT M_gPacketTimeout;       /* "g" procotol                  */
  182. KEWSHORT M_fPacketTimeout;       /* "f" procotol                  */
  183. KEWSHORT M_tPacketTimeout;       /* "t" procotol                  */
  184. KEWSHORT M_startupTimeout;       /* pre-procotol exchanges        */
  185. KEWSHORT M_MaxErr= 10;        /* Allowed errors per single packet    */
  186. KEWSHORT M_MaxErr;            /* Allowed errors per single packet    */
  187. KEWSHORT M_xfer_bufsize;      /* Buffering used for file transfers */
  188. static KEWSHORT M_priority = 999;
  189. static KEWSHORT M_prioritydelta = 999;
  190.  
  191. boolean bmodemflag[MODEM_LAST];
  192.  
  193. static FLAGTABLE modemFlags[] = {
  194.    { "carrierdetect",  MODEM_CD,          B_LOCAL },
  195.    { "direct",         MODEM_DIRECT,      B_LOCAL },
  196.    { "fixedspeed",     MODEM_FIXEDSPEED,  B_LOCAL },
  197.    { "variablepacket", MODEM_VARIABLEPACKET, B_LOCAL },
  198.    { "largepacket",    MODEM_LARGEPACKET, B_LOCAL | B_OBSOLETE },
  199.    { nil(char) }
  200. }           ;
  201.  
  202. static CONFIGTABLE modemtable[] = {
  203.    { "answer",        (char **) &answer,       B_LIST   | B_UUCICO },
  204.    { "answertimeout", (char **) &answerTimeout,B_SHORT| B_UUCICO },
  205.    { "biggpacketsize",(char **) &GPacketSize,  B_SHORT| B_UUCICO },
  206.    { "biggwindowsize",(char **) &GWindowSize,  B_SHORT| B_UUCICO },
  207.    { "chardelay",     (char **) &M_charDelay,  B_SHORT| B_UUCICO },
  208.    { "connect",       (char **) &connect,      B_LIST   | B_UUCICO },
  209.    { "description",   &dummy,                  B_TOKEN  },
  210.    { "device",        &M_device,               B_TOKEN| B_UUCICO | B_REQUIRED },
  211.    { "dialprefix",    &dialPrefix,B_STRING | B_UUCICO | B_REQUIRED },
  212.    { "dialsuffix",    &dialSuffix,             B_STRING | B_UUCICO },
  213.    { "dialtimeout",   (char **) &dialTimeout,  B_SHORT| B_UUCICO },
  214.    { "fpacketsize",   (char **) &M_fPacketSize,B_SHORT| B_UUCICO },
  215.    { "fpackettimeout",(char **) &M_fPacketTimeout, B_SHORT | B_UUCICO },
  216.    { "gpacketsize",   (char **) &gPacketSize,  B_SHORT| B_UUCICO },
  217.    { "gpackettimeout",(char **) &M_gPacketT